package com.keggview.application.controls;

import org.eclipse.jface.viewers.DialogCellEditor;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.FontDialog;

public class FontDataDialogCellEditor extends DialogCellEditor {
    /**
     * Creates a new Font dialog cell editor parented under the given control.
     * The cell editor value is <code>null</code> initially, and has no 
     * validator.
     *
     * @param parent the parent control
     */
    protected FontDataDialogCellEditor(Composite parent) {
       super(parent);
    }

    /**
     * @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(Control)
     */
    @SuppressWarnings("deprecation")
	protected Object openDialogBox(Control cellEditorWindow) {
       FontDialog ftDialog = new FontDialog(cellEditorWindow.getShell());
       @SuppressWarnings("unused")
       String value = (String) getValue();

       if (getValue() != null) {
          ftDialog.setFontData((FontData)getValue());
       }
       FontData fData = ftDialog.open();
			
       if (fData != null) {
	    return fData;
       }
       return getValue();
    }
 }